package com.lxk.mall.pms.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lxk.mall.pms.domain.PmsProductFavorite;
import com.lxk.mall.pms.domain.vo.favorite.PmsProductFavoriteVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;

/**
 * 商品收藏Mapper接口
 *
 * @author Lion Li
 * @date 2024-06-06
 */
public interface PmsProductFavoriteMapper extends BaseMapperPlus<PmsProductFavorite, PmsProductFavoriteVo> {
    default PmsProductFavorite selectByUserIdAndSpuId(Long userId, Long spuId) {
        return selectOne(new LambdaQueryWrapper<PmsProductFavorite>().eq(PmsProductFavorite::getUserId, userId).eq(PmsProductFavorite::getSpuId, spuId));
    }

    default Long selectCountByUserId(Long userId) {
        return selectCount(new LambdaQueryWrapper<PmsProductFavorite>().eq(PmsProductFavorite::getUserId, userId));
    }
}
